version: "3.9"

services:
#    nginx:
#      container_name: match-nginx
#      image: match-nginx
#      build: ./nginx
#      restart: always
#      ports:
#        - "8080:80"
#      networks:
#        - awesome
#      command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
#      depends_on:
#        - client
#        - server
#        - postgres

#    client:
#        container_name: matchthree-client
#        image: matchthree-client
#        build:
#            context: .
#            dockerfile: Dockerfile.client
#            args:
#              CLIENT_PORT: ${CLIENT_PORT}
#        restart: always
#        networks:
#          - awesome
#        ports:
#            - "${CLIENT_PORT}:80"
#        environment:
#          - CLIENT_PORT=${CLIENT_PORT}
#          - SERVER_PORT=${SERVER_PORT}

    server:
        container_name: match-server
        image: match-server
        build:
            context: .
            dockerfile: Dockerfile.server
            args:
              SERVER_PORT: ${SERVER_PORT}
        restart: always
        networks:
          - awesome
        depends_on:
          - postgres
#          - client
        links:
          - postgres
        ports:
            - "${SERVER_PORT}:${SERVER_PORT}"
        environment:
          SERVER_PORT: ${SERVER_PORT}
          NODE_ENV: production
        command: sh -c "sleep 10 && node /app/packages/server/dist/index.js"

    postgres:
      image: postgres:14
      ports:
        - "${POSTGRES_PORT}:${POSTGRES_PORT}"
      environment:
        POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
        POSTGRES_USER: ${POSTGRES_USER}
        POSTGRES_DB: ${POSTGRES_DB}
      restart: always
      env_file:
        - .env
      networks:
        - awesome
      volumes:
        - ./tmp/pgdata:/var/lib/postgresql/data

#    pgadmin:
#      container_name: pgadmin
#      image: dpage/pgadmin4:4.18
#      restart: always
#      environment:
#        PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
#        PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
#        PGADMIN_LISTEN_PORT: ${PGADMIN_LISTEN_PORT}
#      ports:
#        - "${PGADMIN_PORT}:${PGADMIN_LISTEN_PORT}"
#      volumes:
#        - pgadmin-data:/var/lib/pgadmin
#      depends_on:
#        - postgres
#      networks:
#        - awesome

#volumes:
#  pgadmin-data:
#    driver: local

networks:
  awesome:
    driver: bridge
